package com.fdhwws.web.domain;

import com.fdh.myjdbcutil.ColumnField;
import com.fdh.myjdbcutil.IMyEntity;
import com.fdh.myjdbcutil.JSONField;

import java.util.List;

public class User implements IMyEntity {
    @ColumnField(type = ColumnField.Type.SET, isPrimaryKey = true)
    private Integer id;

    @ColumnField
    private String username;

    @ColumnField
    private String password;

    @ColumnField
    private Boolean valid;

    @ColumnField
    private Boolean admin;

    public User() {
    }

    public User(Integer id, String username, String password, Boolean valid, Boolean admin) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.valid = valid;
        this.admin = admin;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Boolean getValid() {
        return valid;
    }

    public void setValid(Boolean valid) {
        this.valid = valid;
    }

    public Boolean getAdmin() {
        return admin;
    }

    public void setAdmin(Boolean admin) {
        this.admin = admin;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", valid=" + valid +
                ", admin=" + admin +
                '}';
    }

    public User safeMode() {
        this.id = null;
        this.password = null;
        this.valid = null;
        this.admin = null;
        return this;
    }
}
